import locale
from urllib.parse import parse_qs

def to_bytes(bytes_or_str):
    if isinstance(bytes_or_str, str):
        value = bytes_or_str.encode('utf-8')
    else:
        value = bytes_or_str
    return value


print(to_bytes(b'foo'))
print(to_bytes('foo'))

assert b'red' > b'blue'

print("%10s = %.2f" % ("test1", 1.245))

name = 'bred'
name.title()

formatted = '{1} = {0:.2f}'.format(1.123, 'chen')
print(formatted)

menu = {'oyster': 'kumamoto'}
#!r万能格式符
print('First {menu1[oyster][0]!r}'.format(menu1=menu))

my_values = parse_qs('red=5&blue=test&green=', keep_blank_values=True)
print(my_values)

print(type(my_values.get('red')))

s = "test"
print(id(s))
s[0] = "T"
print(s, "id(s) = ", id(s))

